<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<div class="project_contents">
	<h1>Gantt Chart</h1>
	<div class="project_in">
	<div class="btn_margin">
	<input type="button" class="btn" onclick="get_gantt(${calendar.currentYear}, ${calendar.currentMonth - 1})"	value="이전" />
	${calendar.currentYear } 년/ ${calendar.currentMonth +	1 } 월
	<input type="button" class="btn" onclick="get_gantt(${calendar.currentYear}, ${calendar.currentMonth + 1})"	value="이후" />
	<input type="button" class="btn" onclick="get_ganttYear(${calendar.currentYear},${calendar.currentMonth})" value="년간"/>
	</div>
		<table id="gantt_table">
			<tr>
				<th id="work_name"></th>
				<c:set var="col" value="${calendar.col}" />
				<c:forEach begin="1" end="${calendar.lastDay }" var="day">
					<th><c:choose>
							<c:when test="${col == 0 }">
								<span id="sunday">${day }</span>
							</c:when>
							<c:when test="${col == 6}">
								<span id="satday">${day }</span>
							</c:when>
							<c:otherwise>
								<span id="day">${day }</span>
							</c:otherwise>
						</c:choose>
					</th>
					<c:set var="col" value="${col + 1 }" />
					<c:if test="${col == 7 }">
						<c:set var="col" value="0" />
					</c:if>
				</c:forEach>
			</tr>

			<c:forEach var="work" items="${workList }">
				<tr>
				<c:if test="${work.workDeadTime.getYear()-100>= calendar.currentYear-2000 && work.workStartTime.getYear()-100<=calendar.currentYear-2000
									&& work.workDeadTime.getMonth()>=calendar.currentMonth && work.workStartTime.getMonth()<=calendar.currentMonth}">
					<th id="work_name" onclick="pick_work(${work.workNo})">${work.workTitle}</th>
				</c:if>
					<c:forEach begin="1" end="${calendar.lastDay }" var="day">
						<c:if test="${work.workDeadTime.getYear()-100>= calendar.currentYear-2000 && work.workStartTime.getYear()-100<=calendar.currentYear-2000
									&& work.workDeadTime.getMonth()>=calendar.currentMonth && work.workStartTime.getMonth()<=calendar.currentMonth}">
							<c:choose>
								<c:when test="${work.workDeadTime.getMonth()>calendar.currentMonth &&	work.workStartTime.getDate()<=day}">
									<td class="work_date line-dotted" id="ganttcolor"><p></p></td>
								</c:when>
								<c:when test="${work.workStartTime.getMonth()<calendar.currentMonth &&	work.workDeadTime.getDate()>=day}">
									<td class="work_date line-dotted" id="ganttcolor"><p></p></td>
								</c:when>
								<c:when test="${work.workDeadTime.getMonth()==calendar.currentMonth && work.workStartTime.getMonth()==calendar.currentMonth
												&& work.workDeadTime.getDate()>=day && work.workStartTime.getDate()<=day}">
									<td class="work_date line-dotted" id="ganttcolor"><p></p></td>
								</c:when>
								<c:otherwise>
								<td class="work_date" id="ganttcolor"></td>
								</c:otherwise>
							</c:choose>
						</c:if>
					
					</c:forEach>
				</tr>
			</c:forEach>
		</table>
	</div>
</div>
<script>
function get_gantt(year, month) {
	$('.project_contents').load('project/gantt/changeMonth', {
		year : year,
		month : month
	});
}
function get_ganttYear(year, month)
{
	$('.project_contents').load('project/gantt/year', {
		year : year,
		month : month
	});
}
</script>
